﻿using Bilibili.Common.Api;
using Bilibili.Model.Parts;
using Bilibili.Model.Resource;
using PCLUntils.Json;
using System;
using System.Threading.Tasks;

namespace Bilibili.WebClient.Api
{
    public sealed class ActivityClient : ClientBase
    {
        public async Task<ReturnModel<TopicModel>> GetTopic(int pageIndex)
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://api.bilibili.com/topic/getlist", $"&page={pageIndex}&pagesize=20", true, ApiProviderBase.Build4);
                string results = await ApiClient.GetResults(apiInfo);
                TopicModel m = results.ParseObject<TopicModel>();
                return BuildSuccessResult(m);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<TopicModel>(ex);
            }
        }
        public async Task<ReturnModel<ActivityModel>> GetList(int pageIndex)
        {
            try
            {
                ApiInfo apiInfo = new ApiInfo("http://api.bilibili.com/event/getlist", $"&page={pageIndex}&pagesize=20", false, ApiProviderBase.Build4);
                string results = await ApiClient.GetResults(apiInfo);
                ActivityModel m = results.ParseObject<ActivityModel>();
                return BuildSuccessResult(m);
            }
            catch (Exception ex)
            {
                return BuildExceptionResult<ActivityModel>(ex);
            }
        }
    }
}